package com.stxx.assistant.controller;

import cn.hutool.core.lang.UUID;
import cn.hutool.json.JSONUtil;
import com.stxx.assistant.domain.SysTask;
import com.stxx.assistant.framwork.domain.R;
import com.stxx.assistant.module.ffmpeg.VideoRecord;
import com.stxx.assistant.service.SysTaskService;
import org.noear.solon.annotation.*;

import java.sql.SQLException;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @author Fuzhenlei
 * @date 2025/02/20 17:15
 */
@Controller
@Mapping("/video")
public class VideoController {
    @Inject
    SysTaskService taskService;
    @Post
    @Mapping("record")
    public R<Object> taskInsert(@Body VideoRecord.Params param) throws SQLException {
        SysTask bo = new SysTask();
        bo.setType("ffmpeg.VideoRecord");
        bo.setId(UUID.fastUUID().toString(true));
        bo.setCreateTime(new Date());
        bo.setStatus(0);
        bo.setBackStatus(0);
        bo.setParams(JSONUtil.toJsonStr(param));
        taskService.insert(bo);
        return R.ok("保存成功");
    }

    @Get
    @Mapping("/stream")
    public R<Map<String,String>> stream(@Param String rtsp) throws SQLException {
        return R.ok("保存成功", null);
    }
}
